package com.im.chat.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.im.chat.model.ChatRecord;
import com.im.chat.util.DateFormat;
import com.im.chat.util.EmojiUtil;
import com.im.chat.util.biz.ImagePropertiesConfig;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class ChatRecordSearchDto {
    private Long chatmsgId;

    private String msgUniqueCode;

    private String content;

    private Integer sendType;

    private Integer isRead;

    private Integer contentType;

    private Long adminId;

    private Long memberId;

    private String memberName;

    private String adminName;

//    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
//    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private String createTime;

    public static ChatRecordSearchDto transDto(
            ChatRecord chatRecord) {
        ChatRecordSearchDto ChatRecordSearchDto = null;
        if (null != chatRecord) {
            ChatRecordSearchDto = new ChatRecordSearchDto(
                    chatRecord.getId(),chatRecord.getMsgUniqueCode(),
                    EmojiUtil.transEmoji(chatRecord.getContent(), ImagePropertiesConfig.EMOJI_SERVER_PATH), chatRecord.getSendType(),
                    chatRecord.getIsRead(),chatRecord.getContentType(),
                    chatRecord.getAdminId(),chatRecord.getMemberId(),chatRecord.getMemberName(),chatRecord.getAdminName(),
                    DateFormat.dateToString(chatRecord.getCreateTime()));
        }
        return ChatRecordSearchDto;
    }
    public static List<ChatRecordSearchDto> transDtos(
            List<ChatRecord> chatRecords) {
        List<ChatRecordSearchDto> chatRecordSearchDtoList = new ArrayList<ChatRecordSearchDto>();
        for(ChatRecord workerPersonUnion:chatRecords){
            ChatRecordSearchDto temp = transDto(workerPersonUnion);
            if(null!=temp){
                chatRecordSearchDtoList.add(temp);
            }
        }
        return chatRecordSearchDtoList;
    }

    public ChatRecordSearchDto() {
    }

    public ChatRecordSearchDto(Long chatmsgId, String msgUniqueCode, String content, Integer sendType, Integer isRead, Integer contentType, Long adminId, Long memberId, String memberName, String adminName, String createTime) {
        this.chatmsgId = chatmsgId;
        this.msgUniqueCode = msgUniqueCode;
        this.content = content;
        this.sendType = sendType;
        this.isRead = isRead;
        this.contentType = contentType;
        this.adminId = adminId;
        this.memberId = memberId;
        this.memberName = memberName;
        this.adminName = adminName;
        this.createTime = createTime;
    }

    public Integer getContentType() {
        return contentType;
    }

    public void setContentType(Integer contentType) {
        this.contentType = contentType;
    }

    public Long getAdminId() {
        return adminId;
    }

    public void setAdminId(Long adminId) {
        this.adminId = adminId;
    }

    public Long getMemberId() {
        return memberId;
    }

    public void setMemberId(Long memberId) {
        this.memberId = memberId;
    }

    public String getMemberName() {
        return memberName;
    }

    public void setMemberName(String memberName) {
        this.memberName = memberName;
    }

    public String getAdminName() {
        return adminName;
    }

    public void setAdminName(String adminName) {
        this.adminName = adminName;
    }

    public Long getChatmsgId() {
        return chatmsgId;
    }

    public void setChatmsgId(Long chatmsgId) {
        this.chatmsgId = chatmsgId;
    }

    public String getMsgUniqueCode() {
        return msgUniqueCode;
    }

    public void setMsgUniqueCode(String msgUniqueCode) {
        this.msgUniqueCode = msgUniqueCode;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public Integer getSendType() {
        return sendType;
    }

    public void setSendType(Integer sendType) {
        this.sendType = sendType;
    }

    public Integer getIsRead() {
        return isRead;
    }

    public void setIsRead(Integer isRead) {
        this.isRead = isRead;
    }

    public String getCreateTime() {
        return createTime;
    }

    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }
}
